class Person { protected String name,city; public Person(String nm,String ct) { name=nm; city=ct; } public void showData() { System.out.println("Name is "+name); System.out.println("City is "+city); } } class Employee extends Person { protected String job; protected int salary; public Employee(String nm,String ct,String jb,int sl) { super(nm,ct); job=jb; salary=sl; } public void showData() { super.showData(); System.out.println("Job is "+ job); System.out.println("Salary is "+salary); } } class Manager extends Employee { protected String branch; public Manager(String nm,String ct,String jb,int sl,String br) { super(nm,ct,jb,sl); branch=br; } public void showData() { super.showData(); System.out.println("Branch is "+branch); } } class demo { public static void main(String args[]) { Person a=new Person("Amit Jain","Amravati"); a.showData(); Employee b; b=new Employee("Nitin Joshi","Nagpur","Clerk",25700); b.showData(); Manager c; c=new Manager("M.Rao","Mumbai","Sr.Manager",65000,"SBI-AMT"); c.showData(); } }
Name is Amit Jain City is Amravati Name is Nitin Joshi City is Nagpur Job is Clerk Salary is 25700 Name is M.Rao City is Mumbai Job is Sr.Manager Salary is 65000 Branch is SBI-AMT